<template>
  <div class="box1">
    <!-- 按钮 -->
    <div class="btn">
      <!-- 刷新按钮 -->
      <div class="btn2">
        <el-button @click="outDo" type="primary" icon="el-icon-refresh"
          >刷新</el-button
        >
      </div>
      <!-- 查询按钮 -->
      <div class="btn3" :model="searchFromData" inline="true">
        <el-button @click="doSearch" type="primary" icon="el-icon-search"
          >查询</el-button
        >
      </div>
      <!-- 输入框 -->
      <div class="btn4">
        <el-input
          placeholder="请输入关键词搜索"
          prefix-icon="el-icon-search"
          v-model="input21"
        >
        </el-input>
      </div>
    </div>
    <!-- 列表数据 -->
    <div class="list1">
      <el-table
        :data="tableData3.slice((currentPage - 1) * pageSize, currentPage * pageSize)"
        border
        style="width: 100%"
        stripe
      >
        <el-table-column prop="number" label="序号" type="index"  align="center"></el-table-column>
        <el-table-column prop="examClass" label="班级" align="center"></el-table-column>
        <el-table-column prop="examActCount" label="试卷类型" align="center"></el-table-column>
        <el-table-column prop="attend" label="应参加人数" align="center"> </el-table-column>
        <el-table-column prop="realMan" label="实际参加人数" align="center"> </el-table-column>
        <el-table-column prop="average" label="平均分" align="center"> </el-table-column>
        <el-table-column prop="passed" label="及格人数" align="center"> </el-table-column>
        <el-table-column prop="createTime" label="创建时间" align="center"> </el-table-column>
        <el-table-column prop="createName" label="创建人" align="center"> </el-table-column>
        <el-table-column fixed="right" label="操作" align="center">
          <template>
            <el-button @click="goXiangQing" size="small" type="success"
              >详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 底部分页 -->
    <div class="footer">
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          @prev-click="upChange"
          @next-click="nextChange"
          :current-page="currentPage"
          :page-sizes="[5, 10, 20, 30]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData3.length"
          background
          strip
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "ChengJi",
  methods: {
    // 刷新按钮功能
    outDo() {
      this.$router.go(0)
    },
    // 搜索按钮功能
    doSearch(){

    },
    //查询功能
    searchFromData(){

    },
    //获取需要渲染到页面中的数据
    // 详情按钮跳转到详情组件（路由跳转）
    goXiangQing() {
        this.$router.push("/XiangQing");
    },
    // 分页器
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.currentPage = 1;
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    },
    upChange(val) {
      console.log(val);
      this.currentPage -= 1;
    },
    nextChange(val) {
      console.log(val);
      this.currentPage += 1;
    },
  },
  mounted(){
    this.$api.chengjiInfo.getTableList().then((res)=>{
      console.log(res.data);
      if(res.data.code == 200){
        console.log(res);
        this.tableData3 = res.data.data;
        console.log(res.data.data);
      }else{
        console.log(111);
      }
    }
    )
  },
  data() {
    return {
      //输入框输入
      input21:'',
      //分页器
      pageSize: 5,//每页的数据条数
      currentPage: 1,//当前页码
      total: 100,//总条数
      // 表格数据
      tableData3: {
        number: "",//序号
        examClass: "",//班级
        examActCount: "",//试卷类型
          attend: "",//应参加人数
          realMan: "",//实际参加人数
          average: "",//平均分
          passed: "",//及格人数
          createTime: "",//创建时间
          createName: "", //创建人
      }
      
    };
  },
}
</script>

<style scoped>
.list1{
  height: 750px;
  overflow-y: auto
}
.btn {
  height: 4px;
  width: 100%;
  margin-bottom: 50px;
}
.btn2,.btn3 {
  float: left;
  height: 35px;
  width: 80px;
  background-color: #409eff;
  border: 1px solid white;
  border-radius: 10px;
  color: azure;
  font-size: 16px;
  font-family: "黑体";
  margin-bottom: 5px;
}
.btn4 {
  float: right;
  height: 25px;
  width: 200px;
}

.btn3 {
  float: right;
  height: 30px;
  margin-right: 9px;
}

.box1 {
  width: 90%;
  margin: 0 auto;
  margin-top: 20px;
  height: 100%;
}
.footer{
  float: right;
}
</style>
